import {reactive} from 'vue'
export const useBaseModel = () => {
  const addUserModel = reactive({
    action:'', //添加还是删除操作
    username:'',
    nickName:'',
    tel:'',
    createBy:'',
    avatar:'https://lxonline.oss-cn-beijing.aliyuncs.com/account/7309683.jpg',
    accountType:'',
    })
    const checkMobile = (rule, value, callback) => {
      // 手机号正则表达式
      const regMobile = /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/
      if (regMobile.test(value)) {
        // 合法的手机号
        return callback()
      }
      callback(new Error('请输入合法的手机号'))
    }
    const rules = reactive({
      username: [
        { required: true, message: '请输入用户名', trigger: 'blur' },
      ],
      nickName: [
        { required: true, message: '请输入昵称', trigger: 'blur' },
      ],
      tel: [
        { required: true, message: '请输入电话号码', trigger: 'blur' },
        { validator: checkMobile, trigger: 'blur' }
      ]
    })
return {
  addUserModel,
   rules
}

}